#include "message.h"
#include <QJsonDocument>

Message::Message(const QString &senderId, const QString &content, const QString &sex)
    : senderId(senderId), content(content), sex(sex) {}

QJsonObject Message::toJson() const {
    QJsonObject json;
    json["senderId"] = senderId;
    json["content"] = content;
    json["sex"] = sex;
    return json;
}

Message Message::fromJson(const QJsonObject &json) {
    QString senderId = json["senderId"].toString();
    QString content = json["content"].toString();
    QString sex = json["sex"].toString();
    return Message(senderId, content, sex);
}
